//
//  SuccessInvestVC.m
//  ZZLC
//
//  Created by 杨春至 on 2018/1/3.
//  Copyright © 2018年 ZhongZeng. All rights reserved.
//

#import "SuccessInvestVC.h"
#import "AppDelegate.h"

@interface SuccessInvestVC ()

@property (nonatomic,strong) UIView *topBgView;

@property (nonatomic,strong) UIButton *goOnInvestBtn;

@end

@implementation SuccessInvestVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"投资成功";
    [self configNavi];
    [self configUI];
}
- (void)configNavi{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithImage:UIImageMake(@"logBack") style:UIBarButtonItemStyleDone target:self action:@selector(backToinvestDetail)];
    self.navigationItem.leftBarButtonItem = leftItem;
}
- (void)configUI{
    self.view.backgroundColor = RGBCOLOR(245, 245, 245);
    [self.view addSubview:self.topBgView];
    [self.view addSubview:self.goOnInvestBtn];
    UIImageView *moneyBg = [[UIImageView alloc]init];
    UILabel *sLb = [[UILabel alloc]initWithFont:[UIFont systemFontOfSize:18] textColor:RGBCOLOR(103, 103, 103)];
    moneyBg.image =  UIImageMake(@"moneyBage");
    sLb.textAlignment = NSTextAlignmentCenter;
    sLb.text = @"恭喜您,投资成功";
    [_topBgView addSubview:moneyBg];
    [_topBgView addSubview:sLb];
    [moneyBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_topBgView);
        make.size.mas_equalTo(CGSizeMake(KWidth*155/755,KWidth*200/755));
        make.centerY.equalTo(_topBgView).offset(-30);
    }];
    [sLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_topBgView);
        make.width.equalTo(_topBgView);
        make.top.equalTo(moneyBg.mas_bottom).offset(30);
    }];
}
- (void)viewDidLayoutSubviews{
    [_topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.width.equalTo(self.view);
        make.height.equalTo(self.view.mas_width).multipliedBy(52.0/72.0);
        make.left.left.equalTo(self.view);
    }];
    [_goOnInvestBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_topBgView.mas_bottom).offset(40);
        make.width.equalTo(@320);
        make.centerX.equalTo(self.view);
        make.height.equalTo(@50);
    }];
}
- (void)backToinvestDetail{
    for (UIViewController *VC in self.navigationController.viewControllers) {
        if ([VC isKindOfClass:NSClassFromString(@"MMMDetailVC")]) {
            [self.navigationController popToViewController:VC animated:YES];
            return;
        }
    }
}
- (UIView *)topBgView{
    if (!_topBgView) {
        _topBgView = [[UIView alloc]init];
        _topBgView.backgroundColor = [UIColor whiteColor];
    }
    return _topBgView;
}
- (UIButton *)goOnInvestBtn{
    if (!_goOnInvestBtn) {
        _goOnInvestBtn = [[UIButton alloc]init];
        [_goOnInvestBtn setTitle:@"继续投资" forState:UIControlStateNormal];
        _goOnInvestBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_goOnInvestBtn setBackgroundImage:UIImageMake(@"btn_me_login") forState:UIControlStateNormal];
        [_goOnInvestBtn bk_addEventHandler:^(id sender) {
            [self.navigationController popToRootViewControllerAnimated:NO];
            [KAppdelegate tabBarSelectAtIndex:1];
        } forControlEvents:UIControlEventTouchUpInside];
    }
    return _goOnInvestBtn;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}



@end
